import React from 'react';
import { Router, Route, Switch, Redirect } from 'dva/router';
import App from './routes/App'
import Film from './routes/Film'
import Cinemas from './routes/Cinemas'
import Center from './routes/Center'
import Detail from './routes/Detail'
import Login from './routes/Login'

function RouterConfig({ history }) {
  return (
    <Router history={history}>
      <Switch>
        {/* 不需要用到选项卡 */}
        <Route path="/login" component={Login}/>

        <Route path="/" render={() =>
          <App>
            <Switch>
              <Route path="/film" component={Film}/>
              <Route path="/cinema" component={Cinemas}/>
              {/*<Route path="/center" component={Center}/>*/}
              <Route path="/center" render={() => localStorage.getItem('token')?<Center/>:<Redirect to='/login'/>}/>

              <Route path='/detail/:id' component={Detail}/>


              <Redirect from='/' to='/film'/>
            </Switch>
          </App>
        } />
      </Switch>
    </Router>
  );
}

export default RouterConfig;
